/*
** add_request.c for  in /home/faye_m//zappy-2011/new_server/src/src
** 
** Made by mouhamed faye
** Login   <faye_m@epitech.net>
** 
** Started on  Wed Jul  6 20:13:40 2011 mouhamed faye
** Last update Sun Jul 10 23:39:31 2011 vincent ricard
*/
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <stdio.h>
#include "types.h"
#include "parser.h"

void	*add_request(Class_player * e, int socket,
		     t_server_params  *p, T_env *a)
{

  int	i = 0;

  t_good_request     *request;
  Class_player	*tmp_team;

  tmp_team =  malloc(sizeof (*tmp_team));
  request = malloc(sizeof(*request));
  printf ("Received \"%s\"  From %d a %d\n", a->buf, a->i, current_time());
  tmp_team = e;
  if (tmp_team == NULL)
    exit(0);
  else
    {
      while (a->tab[i] < getMaxFd())
	{
	  if (socket == a->tab[i])
	    {
	      if ((request = request_parser(a->buf, p->time)) != NULL &&
		  tmp_team->compteur_tab < 10)
		{
		  tmp_team->tab_req[tmp_team->compteur_tab] = *request;
		  tmp_team->compteur_tab += 1;
		  break;
		}
	    }
	  i++;
	}
    }
}
